package com.ebeijia.controller;

import javax.servlet.http.HttpServletRequest;

import com.ebeijia.context.UserContext;
import org.springframework.web.servlet.ModelAndView;


/**
 * Created by YPJ on 2016/5/12.
 */
public class BaseController {


    protected ModelAndView newModelAndView(String viewName) {
        return new ModelAndView(viewName);
    }


    /**
     * 设置usre context
     *
     * @param request
     * @param userContext
     */
    protected void refreshUserContext(HttpServletRequest request, UserContext userContext) {
        if (userContext == null) {
            throw new IllegalArgumentException("can not put null to session!");
        }
        request.getSession().setAttribute("userManage", userContext);
    }

}
